using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;

namespace PokerLearner.Poker
{
	[Serializable]
	public class Player : IEquatable<Player>
	{
		private int stack;
		public int Stack
		{
			get { return stack; }
			set 
			{ 
				stack = value;
				if (StackChanged != null)
				{
					StackChanged(this, new PlayerEventArgs(this));
				}
			}
		}

		private string name;
		public string Name
		{
			get { return name; }
		}

		

		#region Constructor

		public Player(string name, int stack)
		{
			this.name = name;
			this.stack = stack;
		}

		#endregion

		#region Object Overrides

		public override bool Equals(object obj)
		{
			Player player = obj as Player;
			if(player != null)
				return Equals(player);
			else
				return false;
		}

		public override int GetHashCode()
		{
			return name.GetHashCode();
		}

		public override string ToString()
		{
			return name;
		}

		#endregion

		#region Events

		public event EventHandler<PlayerEventArgs> StackChanged;

		#endregion

		#region IEquatable<Player> Members

		public bool Equals(Player other)
		{
			return name.CompareTo(other.Name) == 0;
		}

		#endregion
	}
}
